package com.cn.gxa.redisutils.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@Service
public class TestService {

    @Autowired
    private RedisTemplate  redisTemplate;

    public  void save(Map<String,Object> map){
        redisTemplate.multi();
            for (String key:map.keySet()){
                if(key.equals("name")){
                    System.out.println(1/0);
                }
                //                 key              value      10       时间类型
                redisTemplate.opsForValue().set(key,map.get(key),40, TimeUnit.SECONDS);

            }
        redisTemplate.exec();
    }



}
